#ifndef QTHREAD_LAMBDA_H_
#define QTHREAD_LAMBDA_H_
#include "qthread.h"
#include <sys/cdefs.h>
template <typename T>
__always_inline constexpr T resolve_slave_func(T host_func){
  return (T)__builtin_slave_func((void*)host_func);
}
#include "qthread.h"
template <typename G> __attribute__((sw64_slave)) void __qthread_run_lambda(G *g) { (*g)(); }
template <typename G> void qthread_run_lambda(G g){
  qthread_spawn(resolve_slave_func(__qthread_run_lambda<G>), &g);
  qthread_join();
}
#define __mpe__ __attribute__((sw64_host))
#define __cpe__ __attribute__((sw64_slave))
#endif
